package com.etone.smartAudit.mapstruct;

import com.etone.smartAudit.domain.DataMetaTask;
import com.etone.smartAudit.dto.DataMetaTask.DataMetaFieldInfoDTO;
import com.etone.smartAudit.dto.DataMetaTask.DataMetaTaskDTO;
import com.etone.smartAudit.dto.task.DataMetaTaskForTaskDTO;
import com.etone.smartAudit.vo.dataMetaTask.DataMetaTaskDetailVO;
import org.mapstruct.*;

/**
 * @author: sovy
 * @date: 2020/11/23
 * @description:
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, imports = {com.alibaba.fastjson.JSONArray.class, com.etone.smartAudit.vo.dataMetaTask.DataMetaFieldInfoVO.class,com.etone.smartAudit.dto.DataMetaTask.DataMetaFieldInfoDTO.class})
public interface DataMetaTaskMapstruct {

    @Mappings({
            @Mapping(target = "fieldInfo", expression = "java(JSONArray.toJSONString(dataMetaTaskDTO.getFieldInfo()))")
    })
    void copy2DataMetaTask(@MappingTarget DataMetaTask dataMetaTask, DataMetaTaskDTO dataMetaTaskDTO);

    @Mappings({
            @Mapping(target = "fieldInfo", expression = "java(JSONArray.parseArray(dataMetaTask.getFieldInfo(),DataMetaFieldInfoVO.class))")
    })
    DataMetaTaskDetailVO getDataMetaTaskDetailVO(DataMetaTask dataMetaTask);

    @Mappings({
            @Mapping(target = "name", source = "taskName"),
            @Mapping(target = "fieldInfo", expression = "java(JSONArray.parseArray(dataMetaTask.getFieldInfo(),DataMetaFieldInfoDTO.class))")
    })
    DataMetaTaskForTaskDTO getDataMetaTaskForTaskDTO(DataMetaTask dataMetaTask);

}
